<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>jQ动画</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }

        .box1{
            position: relative;
            top: 0;
            left: 50px;
            width: 150px;
            height: 150px;
            background-color: #f00;
        }

        .box2{
            position: relative;
            top: 0px;
            left: 50px;
            width: 150px;
            height: 150px;
            background-color: #00f;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="box2"></div>

    <script src="../lib/jquery/jquery.min.js"></script>
    <script type="text/javascript">
        var $box1 = $(".box1"),
            $box2 = $(".box2");

        $box1.click(function (){
            $(this).animate({
                left: "300px",
                // width: 300, // 加不加单位全凭喜好
                // height: 300
            }, "fast", "linear", function(){
                console.log("动画执行完毕后的回调函数");
            })
            $box2.animate({
                left: "300px",
                // width: 300, // 加不加单位全凭喜好
                // height: 300
            }, 3000, "swing")
        })
    </script>
</body>
</html>